import java.util.*;
/** 
 * Class Room - a room in an adventure game.
 *
 * This class is part of the "World of Zuul" application. 
 * "World of Zuul" is a very simple, text based adventure game.  
 *
 * A "Room" represents one location in the scenery of the game.  It is 
 * connected to other rooms via exits.  The exits are labelled north, 
 * east, south, west.  For each direction, the room stores a reference
 * to the neighboring room, or null if there is no exit in that direction.
 * 
 * @author  Michael Kölling and David J. Barnes
 * @version 2016.02.29
 */
public class Room 
{
    private String description;
    private HashMap<String, Room> rooms = new HashMap<>();
    private HashMap<String, Thing> things = new HashMap<>();
    private HashMap<String, Monster> monsters = new HashMap<>();
    
    /**
     * Create a room described "description". Initially, it has
     * no exits. "description" is something like "a kitchen" or
     * "an open court yard".
     * @param description The room's description.
     */
    public Room(String description) 
    {
        this.description = description;
    }
    
    public void putThing(Thing thing)
    {
        if (things.get(thing.getName()) == null) {
            this.things.put(thing.getName(), thing);
        }
    }
    
    public String checkDanyao()
    {
        return "八品解毒丹";
    }
    
    public void putMonster(Monster monster)
    {
        if (monsters.get(monster.getName()) == null) {
            this.monsters.put(monster.getName(), monster);
        }
    }
    
    public void checkThing() 
    {
        if (!things.isEmpty()) {
            System.out.print("你在房间里面找到了：");
            for (String name : things.keySet()) {
                System.out.print(name + " ");
            }
            System.out.println();
        }
        else {
            System.out.println("你在这个房间没有找到任何东西");
        }
    }
    
    public String checkHost()
    {
        String name = "墓室主人";
        return name;
    }
    
    public void checkMonster() 
    {
        if (!monsters.isEmpty()) {
            System.out.println("轰轰轰轰轰，进来的石门关闭了");
            System.out.print("这个房间里面的敌人有：");
            System.out.println();
            for (String name : monsters.keySet()) {
                System.out.print(name + " ");
            }
            System.out.println("你必须把所有敌人打败后才能离开这个房间");
            System.out.println();
        }
    }
    
    public boolean checkRoomMonster()
    {
        if (monsters.isEmpty()) {
            return true;
        }
        else {
            return false;
        }
    }
    
    public Monster getMonster(String name)
    {
        return monsters.get(name);
    }
    
    public void removeMonster(String name)
    {
        Monster m = monsters.remove(name);
        if (m == null) {
            System.out.println("这个房间里面并没有这个怪物：" + name);
        }
    }
    
    public void removeThing(String name)
    {
        Thing f = things.remove(name);
        if (f == null) {
            System.out.println("这个房间里面并没有这个东西：" + name);
        }
    }
    
    public Thing getThing(String name)
    {
        return things.get(name);
    }
    
    /**
     * Define the exits of this room.  Every direction either leads
     * to another room or is null (no exit there).
     * @param north The north exit.
     * @param east The east east.
     * @param south The south exit.
     * @param west The west exit.
     */
    public void setExit(String direction, Room room) {
        this.rooms.put(direction, room);
    }
    
    public void printExits() {
        System.out.println("这个房间有这些入口: ");
        for (String str : rooms.keySet()) {
            System.out.print(str + " ");
        }
        System.out.println();
    }
    
    public Room goNext(String direction) {
        return this.rooms.get(direction);
    }
    
    /**
     * @return The description of the room.
     */
    public String getDescription()
    {
        return description;
    }

}
